using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using PickGold.Charting.Utilities;
using PickGold.Charting.Design;

namespace PickGold.Charting
{
	[SRDescription("DescriptionAttributeTitle5")]
	[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	public class Title : ChartNamedElement, IDisposable, IChartMapArea
	{
		private ContentAlignment _alignment;
		private Color _backColor;
		private GradientStyle _backGradientStyle;
		private ChartHatchStyle _backHatchStyle;
		private string _backImage;
		private ChartImageAlignmentStyle _backImageAlignment;
		private Color _backImageTransparentColor;
		private ChartImageWrapMode _backImageWrapMode;
		private Color _backSecondaryColor;
		private Color _borderColor;
		private ChartDashStyle _borderDashStyle;
		private int _borderWidth;
		private string _dockedToChartArea;
		private Docking _docking;
		private int _dockingOffset;
		private System.Drawing.Font _font;
		private FontCache _fontCache;
		private Color _foreColor;
		private bool _isDockedInsideChartArea;
		private string _mapAreaAttributes;
		private ElementPosition _position;
		private string _postbackValue;
		private Color _shadowColor;
		private int _shadowOffset;
		private TextStyle _style;
		private string _text;
		private TextOrientation _textOrientation;
		private string _toolTip;
		private string _url;
		private bool _visible;
		internal int titleBorderSpacing;

		public Title()
		{
			this.titleBorderSpacing = 4;
			this._text = string.Empty;
			this._visible = true;
			this._backColor = Color.Empty;
			this._backImage = "";
			this._backImageTransparentColor = Color.Empty;
			this._backSecondaryColor = Color.Empty;
			this._shadowColor = Color.FromArgb(0x80, 0, 0, 0);
			this._borderColor = Color.Empty;
			this._borderWidth = 1;
			this._borderDashStyle = ChartDashStyle.Solid;
			this._fontCache = new FontCache();
			this._foreColor = Color.Black;
			this._alignment = ContentAlignment.MiddleCenter;
			this._dockedToChartArea = "NotSet";
			this._isDockedInsideChartArea = true;
			this._toolTip = string.Empty;
			this._url = string.Empty;
			this._mapAreaAttributes = string.Empty;
			this._postbackValue = string.Empty;
			this.Initialize(string.Empty, Docking.Top, null, Color.Black);
		}

		public Title(string text)
		{
			this.titleBorderSpacing = 4;
			this._text = string.Empty;
			this._visible = true;
			this._backColor = Color.Empty;
			this._backImage = "";
			this._backImageTransparentColor = Color.Empty;
			this._backSecondaryColor = Color.Empty;
			this._shadowColor = Color.FromArgb(0x80, 0, 0, 0);
			this._borderColor = Color.Empty;
			this._borderWidth = 1;
			this._borderDashStyle = ChartDashStyle.Solid;
			this._fontCache = new FontCache();
			this._foreColor = Color.Black;
			this._alignment = ContentAlignment.MiddleCenter;
			this._dockedToChartArea = "NotSet";
			this._isDockedInsideChartArea = true;
			this._toolTip = string.Empty;
			this._url = string.Empty;
			this._mapAreaAttributes = string.Empty;
			this._postbackValue = string.Empty;
			this.Initialize(text, Docking.Top, null, Color.Black);
		}

		public Title(string text, Docking docking)
		{
			this.titleBorderSpacing = 4;
			this._text = string.Empty;
			this._visible = true;
			this._backColor = Color.Empty;
			this._backImage = "";
			this._backImageTransparentColor = Color.Empty;
			this._backSecondaryColor = Color.Empty;
			this._shadowColor = Color.FromArgb(0x80, 0, 0, 0);
			this._borderColor = Color.Empty;
			this._borderWidth = 1;
			this._borderDashStyle = ChartDashStyle.Solid;
			this._fontCache = new FontCache();
			this._foreColor = Color.Black;
			this._alignment = ContentAlignment.MiddleCenter;
			this._dockedToChartArea = "NotSet";
			this._isDockedInsideChartArea = true;
			this._toolTip = string.Empty;
			this._url = string.Empty;
			this._mapAreaAttributes = string.Empty;
			this._postbackValue = string.Empty;
			this.Initialize(text, docking, null, Color.Black);
		}

		public Title(string text, Docking docking, System.Drawing.Font font, Color color)
		{
			this.titleBorderSpacing = 4;
			this._text = string.Empty;
			this._visible = true;
			this._backColor = Color.Empty;
			this._backImage = "";
			this._backImageTransparentColor = Color.Empty;
			this._backSecondaryColor = Color.Empty;
			this._shadowColor = Color.FromArgb(0x80, 0, 0, 0);
			this._borderColor = Color.Empty;
			this._borderWidth = 1;
			this._borderDashStyle = ChartDashStyle.Solid;
			this._fontCache = new FontCache();
			this._foreColor = Color.Black;
			this._alignment = ContentAlignment.MiddleCenter;
			this._dockedToChartArea = "NotSet";
			this._isDockedInsideChartArea = true;
			this._toolTip = string.Empty;
			this._url = string.Empty;
			this._mapAreaAttributes = string.Empty;
			this._postbackValue = string.Empty;
			this.Initialize(text, docking, font, color);
		}

		internal void CalcTitlePosition(ChartGraphics chartGraph, ref RectangleF chartAreasRectangle, ref RectangleF frameTitlePosition, float elementSpacing)
		{
			if ((!frameTitlePosition.IsEmpty && this.Position.Auto) && ((this.Docking == Docking.Top) && (this.DockedToChartArea == "NotSet")))
			{
				this.Position.SetPositionNoAuto(frameTitlePosition.X + elementSpacing, frameTitlePosition.Y, frameTitlePosition.Width - (2f * elementSpacing), frameTitlePosition.Height);
				frameTitlePosition = RectangleF.Empty;
			}
			else
			{
				RectangleF ef = new RectangleF();
				SizeF size = new SizeF(chartAreasRectangle.Width, chartAreasRectangle.Height);
				if (this.IsTextVertical)
				{
					float width = size.Width;
					size.Width = size.Height;
					size.Height = width;
				}
				size.Width -= 2f * elementSpacing;
				size.Height -= 2f * elementSpacing;
				size = chartGraph.GetAbsoluteSize(size);
				SizeF relativeSize = chartGraph.MeasureString(this.Text.Replace(@"\n", "\n"), this.Font, size, StringFormat.GenericTypographic, this.GetTextOrientation());
				if (this.BackGroundIsVisible)
				{
					relativeSize.Width += this.titleBorderSpacing;
					relativeSize.Height += this.titleBorderSpacing;
				}
				if (this.IsTextVertical)
				{
					float num2 = relativeSize.Width;
					relativeSize.Width = relativeSize.Height;
					relativeSize.Height = num2;
				}
				relativeSize = chartGraph.GetRelativeSize(relativeSize);
				ef.Height = relativeSize.Height;
				ef.Width = relativeSize.Width;
				if (!float.IsNaN(relativeSize.Height) && !float.IsNaN(relativeSize.Width))
				{
					if (this.Docking == Docking.Top)
					{
						ef.Y = chartAreasRectangle.Y + elementSpacing;
						ef.X = chartAreasRectangle.X + elementSpacing;
						ef.Width = (chartAreasRectangle.Right - ef.X) - elementSpacing;
						if (ef.Width < 0f)
						{
							ef.Width = 0f;
						}
						chartAreasRectangle.Height -= ef.Height + elementSpacing;
						chartAreasRectangle.Y = ef.Bottom;
					}
					else if (this.Docking == Docking.Bottom)
					{
						ef.Y = (chartAreasRectangle.Bottom - relativeSize.Height) - elementSpacing;
						ef.X = chartAreasRectangle.X + elementSpacing;
						ef.Width = (chartAreasRectangle.Right - ef.X) - elementSpacing;
						if (ef.Width < 0f)
						{
							ef.Width = 0f;
						}
						chartAreasRectangle.Height -= ef.Height + elementSpacing;
					}
					if (this.Docking == Docking.Left)
					{
						ef.X = chartAreasRectangle.X + elementSpacing;
						ef.Y = chartAreasRectangle.Y + elementSpacing;
						ef.Height = (chartAreasRectangle.Bottom - ef.Y) - elementSpacing;
						if (ef.Height < 0f)
						{
							ef.Height = 0f;
						}
						chartAreasRectangle.Width -= ef.Width + elementSpacing;
						chartAreasRectangle.X = ef.Right;
					}
					if (this.Docking == Docking.Right)
					{
						ef.X = (chartAreasRectangle.Right - relativeSize.Width) - elementSpacing;
						ef.Y = chartAreasRectangle.Y + elementSpacing;
						ef.Height = (chartAreasRectangle.Bottom - ef.Y) - elementSpacing;
						if (ef.Height < 0f)
						{
							ef.Height = 0f;
						}
						chartAreasRectangle.Width -= ef.Width + elementSpacing;
					}
					if (this.DockingOffset != 0)
					{
						if ((this.Docking == Docking.Top) || (this.Docking == Docking.Bottom))
						{
							ef.Y += this.DockingOffset;
						}
						else
						{
							ef.X += this.DockingOffset;
						}
					}
					this.Position.SetPositionNoAuto(ef.X, ef.Y, ef.Width, ef.Height);
				}
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (this._fontCache != null)
				{
					this._fontCache.Dispose();
					this._fontCache = null;
				}
				if (this._position != null)
				{
					this._position.Dispose();
					this._position = null;
				}
			}
		}

		internal static void DrawStringWithStyle(ChartGraphics chartGraph, string titleText, TextStyle textStyle, System.Drawing.Font font, RectangleF absPosition, Color foreColor, Color shadowColor, int shadowOffset, StringFormat format, TextOrientation orientation)
		{
			if (titleText.Length > 0)
			{
				if (textStyle == TextStyle.Default)
				{
					using (SolidBrush brush = new SolidBrush(foreColor))
					{
						chartGraph.DrawString(titleText, font, brush, absPosition, format, orientation);
						return;
					}
				}
				if (textStyle == TextStyle.Frame)
				{
					using (GraphicsPath path = new GraphicsPath())
					{
						path.AddString(titleText, font.FontFamily, (int)font.Style, font.Size * 1.3f, absPosition, format);
						path.CloseAllFigures();
						using (Pen pen = new Pen(foreColor, 1f))
						{
							chartGraph.DrawPath(pen, path);
						}
						return;
					}
				}
				if (textStyle == TextStyle.Embed)
				{
					RectangleF rect = new RectangleF(absPosition.Location, absPosition.Size);
					rect.X--;
					rect.Y--;
					using (SolidBrush brush2 = new SolidBrush(shadowColor))
					{
						chartGraph.DrawString(titleText, font, brush2, rect, format, orientation);
					}
					rect.X += 2f;
					rect.Y += 2f;
					using (SolidBrush brush3 = new SolidBrush(ChartGraphics.GetGradientColor(Color.White, foreColor, 0.3)))
					{
						chartGraph.DrawString(titleText, font, brush3, rect, format, orientation);
					}
					using (SolidBrush brush4 = new SolidBrush(foreColor))
					{
						chartGraph.DrawString(titleText, font, brush4, absPosition, format, orientation);
						return;
					}
				}
				if (textStyle == TextStyle.Emboss)
				{
					RectangleF ef2 = new RectangleF(absPosition.Location, absPosition.Size);
					ef2.X++;
					ef2.Y++;
					using (SolidBrush brush5 = new SolidBrush(shadowColor))
					{
						chartGraph.DrawString(titleText, font, brush5, ef2, format, orientation);
					}
					ef2.X -= 2f;
					ef2.Y -= 2f;
					using (SolidBrush brush6 = new SolidBrush(ChartGraphics.GetGradientColor(Color.White, foreColor, 0.3)))
					{
						chartGraph.DrawString(titleText, font, brush6, ef2, format, orientation);
					}
					using (SolidBrush brush7 = new SolidBrush(foreColor))
					{
						chartGraph.DrawString(titleText, font, brush7, absPosition, format, orientation);
						return;
					}
				}
				if (textStyle == TextStyle.Shadow)
				{
					RectangleF ef3 = new RectangleF(absPosition.Location, absPosition.Size);
					ef3.X += shadowOffset;
					ef3.Y += shadowOffset;
					using (SolidBrush brush8 = new SolidBrush(shadowColor))
					{
						chartGraph.DrawString(titleText, font, brush8, ef3, format, orientation);
					}
					using (SolidBrush brush9 = new SolidBrush(foreColor))
					{
						chartGraph.DrawString(titleText, font, brush9, absPosition, format, orientation);
					}
				}
			}
		}

		private TextOrientation GetTextOrientation()
		{
			if (this.TextOrientation != TextOrientation.Auto)
			{
				return this.TextOrientation;
			}
			if (this.Position.Auto)
			{
				if (this.Docking == Docking.Left)
				{
					return TextOrientation.Rotated270;
				}
				if (this.Docking == Docking.Right)
				{
					return TextOrientation.Rotated90;
				}
			}
			return TextOrientation.Horizontal;
		}

		private void Initialize(string text, Docking docking, System.Drawing.Font font, Color color)
		{
			this._position = new ElementPosition(this);
			this._font = this._fontCache.DefaultFont;
			this._text = text;
			this._docking = docking;
			this._foreColor = color;
			if (font != null)
			{
				this._font = font;
			}
		}

		internal void Invalidate(bool invalidateTitleOnly)
		{
		}

		internal bool IsVisible()
		{
			if (!this.Visible)
			{
				return false;
			}
			if (((this.DockedToChartArea.Length > 0) && (base.Chart != null)) && (base.Chart.ChartAreas.IndexOf(this.DockedToChartArea) >= 0))
			{
				ChartArea area = base.Chart.ChartAreas[this.DockedToChartArea];
				if (!area.Visible)
				{
					return false;
				}
			}
			return true;
		}

		internal void Paint(ChartGraphics chartGraph)
		{
			if (this.IsVisible())
			{
				string text = this.Text;
				RectangleF rectF = this.Position.ToRectangleF();
				if (((!this.Position.Auto && (base.Common != null)) && (base.Common.ChartPicture != null)) && ((rectF.Width == 0f) || (rectF.Height == 0f)))
				{
					SizeF size = new SizeF((rectF.Width == 0f) ? ((float)base.Common.ChartPicture.Width) : rectF.Width, (rectF.Height == 0f) ? ((float)base.Common.ChartPicture.Height) : rectF.Height);
					if (this.IsTextVertical)
					{
						float width = size.Width;
						size.Width = size.Height;
						size.Height = width;
					}
					size = chartGraph.GetAbsoluteSize(size);
					SizeF relativeSize = chartGraph.MeasureString(text.Replace(@"\n", "\n"), this.Font, size, StringFormat.GenericTypographic, this.GetTextOrientation());
					if (this.BackGroundIsVisible)
					{
						relativeSize.Width += this.titleBorderSpacing;
						relativeSize.Height += this.titleBorderSpacing;
					}
					if (this.IsTextVertical)
					{
						float num2 = relativeSize.Width;
						relativeSize.Width = relativeSize.Height;
						relativeSize.Height = num2;
					}
					relativeSize = chartGraph.GetRelativeSize(relativeSize);
					if (rectF.Width == 0f)
					{
						rectF.Width = relativeSize.Width;
						if (((this.Alignment == ContentAlignment.BottomRight) || (this.Alignment == ContentAlignment.MiddleRight)) || (this.Alignment == ContentAlignment.TopRight))
						{
							rectF.X -= rectF.Width;
						}
						else if (((this.Alignment == ContentAlignment.BottomCenter) || (this.Alignment == ContentAlignment.MiddleCenter)) || (this.Alignment == ContentAlignment.TopCenter))
						{
							rectF.X -= rectF.Width / 2f;
						}
					}
					if (rectF.Height == 0f)
					{
						rectF.Height = relativeSize.Height;
						if (((this.Alignment == ContentAlignment.BottomRight) || (this.Alignment == ContentAlignment.BottomCenter)) || (this.Alignment == ContentAlignment.BottomLeft))
						{
							rectF.Y -= rectF.Height;
						}
						else if (((this.Alignment == ContentAlignment.MiddleCenter) || (this.Alignment == ContentAlignment.MiddleLeft)) || (this.Alignment == ContentAlignment.MiddleRight))
						{
							rectF.Y -= rectF.Height / 2f;
						}
					}
				}
				RectangleF rectangle = new RectangleF(rectF.Location, rectF.Size);
				rectangle = chartGraph.GetAbsoluteRectangle(rectangle);
				if (this.BackGroundIsVisible && base.Common.ProcessModePaint)
				{
					chartGraph.FillRectangleRel(rectF, this.BackColor, this.BackHatchStyle, this.BackImage, this.BackImageWrapMode, this.BackImageTransparentColor, this.BackImageAlignment, this.BackGradientStyle, this.BackSecondaryColor, this.BorderColor, this.BorderWidth, this.BorderDashStyle, this.ShadowColor, this.ShadowOffset, PenAlignment.Inset);
				}
				else
				{
					SizeF absoluteSize = chartGraph.GetAbsoluteSize(rectF.Size);
					SizeF ef6 = chartGraph.MeasureString(text.Replace(@"\n", "\n"), this.Font, absoluteSize, StringFormat.GenericTypographic, this.GetTextOrientation());
					ef6 = chartGraph.GetRelativeSize(ef6);
					RectangleF ef7 = new RectangleF(rectF.X, rectF.Y, ef6.Width, ef6.Height);
					if (((this.Alignment == ContentAlignment.BottomCenter) || (this.Alignment == ContentAlignment.BottomLeft)) || (this.Alignment == ContentAlignment.BottomRight))
					{
						ef7.Y = rectF.Bottom - ef7.Height;
					}
					else if (((this.Alignment == ContentAlignment.MiddleCenter) || (this.Alignment == ContentAlignment.MiddleLeft)) || (this.Alignment == ContentAlignment.MiddleRight))
					{
						ef7.Y = (rectF.Y + (rectF.Height / 2f)) - (ef7.Height / 2f);
					}
					if (((this.Alignment == ContentAlignment.BottomRight) || (this.Alignment == ContentAlignment.MiddleRight)) || (this.Alignment == ContentAlignment.TopRight))
					{
						ef7.X = rectF.Right - ef7.Width;
					}
					else if (((this.Alignment == ContentAlignment.BottomCenter) || (this.Alignment == ContentAlignment.MiddleCenter)) || (this.Alignment == ContentAlignment.TopCenter))
					{
						ef7.X = (rectF.X + (rectF.Width / 2f)) - (ef7.Width / 2f);
					}
					if (true)
					{
						chartGraph.FillRectangleRel(ef7, Color.FromArgb(0, Color.White), ChartHatchStyle.None, string.Empty, ChartImageWrapMode.Tile, this.BackImageTransparentColor, this.BackImageAlignment, GradientStyle.None, this.BackSecondaryColor, Color.Transparent, 0, this.BorderDashStyle, Color.Transparent, 0, PenAlignment.Inset);
					}
					chartGraph.EndHotRegion();
				}
				if (base.Common.ProcessModePaint)
				{
					base.Common.Chart.CallOnPrePaint(new ChartPaintEventArgs(this, chartGraph, base.Common, this.Position));
				}
				if (this.BackGroundIsVisible)
				{
					rectangle.Width -= this.titleBorderSpacing;
					rectangle.Height -= this.titleBorderSpacing;
					rectangle.X += ((float)this.titleBorderSpacing) / 2f;
					rectangle.Y += ((float)this.titleBorderSpacing) / 2f;
				}
				using (StringFormat format = new StringFormat())
				{
					format.Alignment = StringAlignment.Center;
					format.LineAlignment = StringAlignment.Center;
					if (((this.Alignment == ContentAlignment.BottomCenter) || (this.Alignment == ContentAlignment.BottomLeft)) || (this.Alignment == ContentAlignment.BottomRight))
					{
						format.LineAlignment = StringAlignment.Far;
					}
					else if (((this.Alignment == ContentAlignment.TopCenter) || (this.Alignment == ContentAlignment.TopLeft)) || (this.Alignment == ContentAlignment.TopRight))
					{
						format.LineAlignment = StringAlignment.Near;
					}
					if (((this.Alignment == ContentAlignment.BottomLeft) || (this.Alignment == ContentAlignment.MiddleLeft)) || (this.Alignment == ContentAlignment.TopLeft))
					{
						format.Alignment = StringAlignment.Near;
					}
					else if (((this.Alignment == ContentAlignment.BottomRight) || (this.Alignment == ContentAlignment.MiddleRight)) || (this.Alignment == ContentAlignment.TopRight))
					{
						format.Alignment = StringAlignment.Far;
					}
					Color baseColor = ChartGraphics.GetGradientColor(this.ForeColor, Color.Black, 0.8);
					int shadowOffset = 1;
					TextStyle textStyle = this.TextStyle;
					if (((textStyle == TextStyle.Default) || (textStyle == TextStyle.Shadow)) && (!this.BackGroundIsVisible && (this.ShadowOffset != 0)))
					{
						textStyle = TextStyle.Shadow;
						baseColor = this.ShadowColor;
						shadowOffset = this.ShadowOffset;
					}
					if (textStyle == TextStyle.Shadow)
					{
						baseColor = (baseColor.A != 0xff) ? baseColor : Color.FromArgb(baseColor.A / 2, baseColor);
					}
					text = text.Replace(@"\n", "\n");
					Matrix matrix = null;
					if (this.IsTextVertical)
					{
						if (this.GetTextOrientation() == TextOrientation.Rotated270)
						{
							format.FormatFlags |= StringFormatFlags.DirectionVertical | StringFormatFlags.DirectionRightToLeft;
							matrix = chartGraph.Transform.Clone();
							PointF empty = PointF.Empty;
							empty.X = rectangle.X + (rectangle.Width / 2f);
							empty.Y = rectangle.Y + (rectangle.Height / 2f);
							Matrix matrix2 = chartGraph.Transform.Clone();
							matrix2.RotateAt(180f, empty);
							chartGraph.Transform = matrix2;
						}
						else if (this.GetTextOrientation() == TextOrientation.Rotated90)
						{
							format.FormatFlags |= StringFormatFlags.DirectionVertical | StringFormatFlags.DirectionRightToLeft;
						}
					}
					DrawStringWithStyle(chartGraph, text, textStyle, this.Font, rectangle, this.ForeColor, baseColor, shadowOffset, format, this.GetTextOrientation());
					if (base.Common.ProcessModePaint)
					{
						base.Common.Chart.CallOnPostPaint(new ChartPaintEventArgs(this, chartGraph, base.Common, this.Position));
					}
					if (matrix != null)
					{
						chartGraph.Transform = matrix;
					}
					if (base.Common.ProcessModeRegions)
					{
						base.Common.HotRegionsList.AddHotRegion(rectF, this.ToolTip, this.Url, this.MapAreaAttributes, this.PostBackValue, this, ChartElementType.Title, string.Empty);
					}
				}
			}
		}

		internal bool ShouldSerializePosition()
		{
			return !this.Position.Auto;
		}

		[PersistenceMode(PersistenceMode.Attribute), NotifyParentProperty(true), SRCategory("CategoryAttributeDocking"), Bindable(true), DefaultValue(0x20), SRDescription("DescriptionAttributeTitle_Alignment")]
		public ContentAlignment Alignment
		{
			get
			{
				return this._alignment;
			}
			set
			{
				this._alignment = value;
				this.Invalidate(false);
			}
		}

		[SRCategory("CategoryAttributeAppearance"), PersistenceMode(PersistenceMode.Attribute), Bindable(true), DefaultValue(typeof(Color), ""), SRDescription("DescriptionAttributeBackColor"), NotifyParentProperty(true), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		public Color BackColor
		{
			get
			{
				return this._backColor;
			}
			set
			{
				this._backColor = value;
				this.Invalidate(true);
			}
		}

		[SRCategory("CategoryAttributeAppearance"), Bindable(true), DefaultValue(0), NotifyParentProperty(true), SRDescription("DescriptionAttributeBackGradientStyle"), PersistenceMode(PersistenceMode.Attribute), Editor(typeof(GradientEditor), typeof(UITypeEditor))]
		public GradientStyle BackGradientStyle
		{
			get
			{
				return this._backGradientStyle;
			}
			set
			{
				this._backGradientStyle = value;
				this.Invalidate(true);
			}
		}

		internal bool BackGroundIsVisible
		{
			get
			{
				if ((this.BackColor.IsEmpty && (this.BackImage.Length <= 0)) && (this.BorderColor.IsEmpty || (this.BorderDashStyle == ChartDashStyle.NotSet)))
				{
					return false;
				}
				return true;
			}
		}

		[PersistenceMode(PersistenceMode.Attribute), SRCategory("CategoryAttributeAppearance"), Bindable(true), DefaultValue(0), NotifyParentProperty(true), SRDescription("DescriptionAttributeBackHatchStyle"), Editor(typeof(HatchStyleEditor), typeof(UITypeEditor))]
		public ChartHatchStyle BackHatchStyle
		{
			get
			{
				return this._backHatchStyle;
			}
			set
			{
				this._backHatchStyle = value;
				this.Invalidate(true);
			}
		}

		[SRCategory("CategoryAttributeAppearance"), NotifyParentProperty(true), Bindable(true), DefaultValue(""), SRDescription("DescriptionAttributeBackImage"), Editor(typeof(ImageValueEditor), typeof(UITypeEditor)), PersistenceMode(PersistenceMode.Attribute)]
		public string BackImage
		{
			get
			{
				return this._backImage;
			}
			set
			{
				this._backImage = value;
				this.Invalidate(true);
			}
		}

		[DefaultValue(0), Bindable(true), SRCategory("CategoryAttributeAppearance"), NotifyParentProperty(true), SRDescription("DescriptionAttributeBackImageAlign"), PersistenceMode(PersistenceMode.Attribute)]
		public ChartImageAlignmentStyle BackImageAlignment
		{
			get
			{
				return this._backImageAlignment;
			}
			set
			{
				this._backImageAlignment = value;
				this.Invalidate(true);
			}
		}

		[PersistenceMode(PersistenceMode.Attribute), Bindable(true), DefaultValue(typeof(Color), ""), NotifyParentProperty(true), SRDescription("DescriptionAttributeImageTransparentColor"), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), SRCategory("CategoryAttributeAppearance")]
		public Color BackImageTransparentColor
		{
			get
			{
				return this._backImageTransparentColor;
			}
			set
			{
				this._backImageTransparentColor = value;
				this.Invalidate(true);
			}
		}

		[NotifyParentProperty(true), SRCategory("CategoryAttributeAppearance"), Bindable(true), DefaultValue(0), SRDescription("DescriptionAttributeImageWrapMode"), PersistenceMode(PersistenceMode.Attribute)]
		public ChartImageWrapMode BackImageWrapMode
		{
			get
			{
				return this._backImageWrapMode;
			}
			set
			{
				this._backImageWrapMode = value;
				this.Invalidate(true);
			}
		}

		[SRCategory("CategoryAttributeAppearance"), PersistenceMode(PersistenceMode.Attribute), Bindable(true), DefaultValue(typeof(Color), ""), NotifyParentProperty(true), SRDescription("DescriptionAttributeBackSecondaryColor"), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		public Color BackSecondaryColor
		{
			get
			{
				return this._backSecondaryColor;
			}
			set
			{
				this._backSecondaryColor = value;
				this.Invalidate(true);
			}
		}

		[DefaultValue(typeof(Color), ""), SRCategory("CategoryAttributeAppearance"), Bindable(true), SRDescription("DescriptionAttributeBorderColor"), NotifyParentProperty(true), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), PersistenceMode(PersistenceMode.Attribute)]
		public Color BorderColor
		{
			get
			{
				return this._borderColor;
			}
			set
			{
				this._borderColor = value;
				this.Invalidate(true);
			}
		}

		[NotifyParentProperty(true), SRCategory("CategoryAttributeAppearance"), Bindable(true), DefaultValue(5), SRDescription("DescriptionAttributeBorderDashStyle"), PersistenceMode(PersistenceMode.Attribute)]
		public ChartDashStyle BorderDashStyle
		{
			get
			{
				return this._borderDashStyle;
			}
			set
			{
				this._borderDashStyle = value;
				this.Invalidate(true);
			}
		}

		[DefaultValue(1), SRCategory("CategoryAttributeAppearance"), Bindable(true), SRDescription("DescriptionAttributeBorderWidth"), NotifyParentProperty(true), PersistenceMode(PersistenceMode.Attribute)]
		public int BorderWidth
		{
			get
			{
				return this._borderWidth;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentOutOfRangeException("value", SR.ExceptionTitleBorderWidthIsNegative);
				}
				this._borderWidth = value;
				this.Invalidate(false);
			}
		}

		[DefaultValue("NotSet"), TypeConverter(typeof(LegendAreaNameConverter)), SRDescription("DescriptionAttributeTitle_DockToChartArea"), PersistenceMode(PersistenceMode.Attribute), NotifyParentProperty(true), SRCategory("CategoryAttributeDocking"), Bindable(true)]
		public string DockedToChartArea
		{
			get
			{
				return this._dockedToChartArea;
			}
			set
			{
				if (value != this._dockedToChartArea)
				{
					if (value.Length == 0)
					{
						this._dockedToChartArea = "NotSet";
					}
					else
					{
						if ((base.Chart != null) && (base.Chart.ChartAreas != null))
						{
							base.Chart.ChartAreas.VerifyNameReference(value);
						}
						this._dockedToChartArea = value;
					}
					this.Invalidate(false);
				}
			}
		}

		[PersistenceMode(PersistenceMode.Attribute), SRCategory("CategoryAttributeDocking"), Bindable(true), DefaultValue(0), SRDescription("DescriptionAttributeTitle_Docking"), NotifyParentProperty(true)]
		public Docking Docking
		{
			get
			{
				return this._docking;
			}
			set
			{
				this._docking = value;
				this.Invalidate(false);
			}
		}

		[NotifyParentProperty(true), Bindable(true), SRDescription("DescriptionAttributeTitle_DockOffset"), SRCategory("CategoryAttributeDocking"), PersistenceMode(PersistenceMode.Attribute), DefaultValue(0)]
		public int DockingOffset
		{
			get
			{
				return this._dockingOffset;
			}
			set
			{
				if (value != this._dockingOffset)
				{
					if ((value < -100) || (value > 100))
					{
						int num = -100;
						int num2 = 100;
						throw new ArgumentOutOfRangeException("value", SR.ExceptionValueMustBeInRange("DockingOffset", num.ToString(CultureInfo.CurrentCulture), num2.ToString(CultureInfo.CurrentCulture)));
					}
					this._dockingOffset = value;
					this.Invalidate(false);
				}
			}
		}

		[DefaultValue(typeof(System.Drawing.Font), "Microsoft Sans Serif, 8pt"), SRCategory("CategoryAttributeAppearance"), Bindable(true), SRDescription("DescriptionAttributeTitle_Font"), NotifyParentProperty(true), PersistenceMode(PersistenceMode.Attribute)]
		public System.Drawing.Font Font
		{
			get
			{
				return this._font;
			}
			set
			{
				this._font = value;
				this.Invalidate(false);
			}
		}

		[SRCategory("CategoryAttributeAppearance"), PersistenceMode(PersistenceMode.Attribute), Bindable(true), DefaultValue(typeof(Color), "Black"), SRDescription("DescriptionAttributeTitle_Color"), NotifyParentProperty(true), TypeConverter(typeof(ColorConverter)), Editor(typeof(ChartColorEditor), typeof(UITypeEditor))]
		public Color ForeColor
		{
			get
			{
				return this._foreColor;
			}
			set
			{
				this._foreColor = value;
				this.Invalidate(true);
			}
		}

		[SRDescription("DescriptionAttributeTitle_DockInsideChartArea"), NotifyParentProperty(true), PersistenceMode(PersistenceMode.Attribute), Bindable(true), DefaultValue(true), SRCategory("CategoryAttributeDocking")]
		public bool IsDockedInsideChartArea
		{
			get
			{
				return this._isDockedInsideChartArea;
			}
			set
			{
				if (value != this._isDockedInsideChartArea)
				{
					this._isDockedInsideChartArea = value;
					this.Invalidate(false);
				}
			}
		}

		private bool IsTextVertical
		{
			get
			{
				TextOrientation textOrientation = this.GetTextOrientation();
				if (textOrientation != TextOrientation.Rotated90)
				{
					return (textOrientation == TextOrientation.Rotated270);
				}
				return true;
			}
		}

		[DefaultValue(""), PersistenceMode(PersistenceMode.Attribute), SRCategory("CategoryAttributeMapArea"), Bindable(true), SRDescription("DescriptionAttributeMapAreaAttributes")]
		public string MapAreaAttributes
		{
			get
			{
				return this._mapAreaAttributes;
			}
			set
			{
				this._mapAreaAttributes = value;
			}
		}

		[Bindable(true), SRDescription("DescriptionAttributeTitle_Position"), PersistenceMode(PersistenceMode.InnerProperty), NotifyParentProperty(true), TypeConverter(typeof(ElementPositionConverter)), SerializationVisibility(SerializationVisibility.Element), SRCategory("CategoryAttributeAppearance")]
		public ElementPosition Position
		{
			get
			{
				if ((base.Chart == null) || (base.Chart.SerializationStatus != SerializationStatus.Saving))
				{
					return this._position;
				}
				if (this._position.Auto)
				{
					return new ElementPosition();
				}
				ElementPosition position = new ElementPosition();
				position.Auto = true;
				position.SetPositionNoAuto(this._position.X, this._position.Y, this._position.Width, this._position.Height);
				return position;
			}
			set
			{
				this._position = value;
				this._position.Parent = this;
				this.Invalidate(false);
			}
		}

		[SRCategory("CategoryAttributeMapArea"), SRDescription("DescriptionAttributePostBackValue"), DefaultValue("")]
		public string PostBackValue
		{
			get
			{
				return this._postbackValue;
			}
			set
			{
				this._postbackValue = value;
			}
		}

		[DefaultValue(typeof(Color), "128, 0, 0, 0"), SRCategory("CategoryAttributeAppearance"), Bindable(true), Editor(typeof(ChartColorEditor), typeof(UITypeEditor)), SRDescription("DescriptionAttributeShadowColor"), NotifyParentProperty(true), TypeConverter(typeof(ColorConverter)), PersistenceMode(PersistenceMode.Attribute)]
		public Color ShadowColor
		{
			get
			{
				return this._shadowColor;
			}
			set
			{
				this._shadowColor = value;
				this.Invalidate(false);
			}
		}

		[DefaultValue(0), SRCategory("CategoryAttributeAppearance"), Bindable(true), SRDescription("DescriptionAttributeShadowOffset"), NotifyParentProperty(true), PersistenceMode(PersistenceMode.Attribute)]
		public int ShadowOffset
		{
			get
			{
				return this._shadowOffset;
			}
			set
			{
				this._shadowOffset = value;
				this.Invalidate(false);
			}
		}

		[SRCategory("CategoryAttributeAppearance"), PersistenceMode(PersistenceMode.Attribute), Bindable(true), DefaultValue(""), SRDescription("DescriptionAttributeTitle_Text"), NotifyParentProperty(true), ParenthesizePropertyName(true)]
		public string Text
		{
			get
			{
				return this._text;
			}
			set
			{
				this._text = (value == null) ? string.Empty : value;
				this.Invalidate(false);
			}
		}

		[NotifyParentProperty(true), SRDescription("DescriptionAttribute_TextOrientation"), PersistenceMode(PersistenceMode.Attribute), SRCategory("CategoryAttributeAppearance"), Bindable(true), DefaultValue(0)]
		public TextOrientation TextOrientation
		{
			get
			{
				return this._textOrientation;
			}
			set
			{
				this._textOrientation = value;
				this.Invalidate(true);
			}
		}

		[DefaultValue(0), SRCategory("CategoryAttributeAppearance"), Bindable(true), SRDescription("DescriptionAttributeTextStyle"), NotifyParentProperty(true), PersistenceMode(PersistenceMode.Attribute)]
		public TextStyle TextStyle
		{
			get
			{
				return this._style;
			}
			set
			{
				this._style = value;
				this.Invalidate(true);
			}
		}

		[SRCategory("CategoryAttributeMapArea"), PersistenceMode(PersistenceMode.Attribute), Bindable(true), SRDescription("DescriptionAttributeToolTip"), DefaultValue("")]
		public string ToolTip
		{
			get
			{
				return this._toolTip;
			}
			set
			{
				this._toolTip = value;
			}
		}

		[Bindable(true), Editor(typeof(UrlValueEditor), typeof(UITypeEditor)), SRCategory("CategoryAttributeMapArea"), SRDescription("DescriptionAttributeUrl"), DefaultValue(""), PersistenceMode(PersistenceMode.Attribute)]
		public string Url
		{
			get
			{
				return this._url;
			}
			set
			{
				this._url = value;
			}
		}

		[ParenthesizePropertyName(true), DefaultValue(true), SRDescription("DescriptionAttributeTitle_Visible"), SRCategory("CategoryAttributeAppearance")]
		public virtual bool Visible
		{
			get
			{
				return this._visible;
			}
			set
			{
				this._visible = value;
				this.Invalidate(false);
			}
		}
	}
}

